package observer

class OfficialAccount(override val observers: ArrayList<Observer<String>> = ArrayList()) : Observable<String> {

    //注册订阅者
    override fun register(observer: Observer<String>) {
        observers.add(observer)
    }

    //取消订阅者注册
    override fun unregister(observer: Observer<String>) {
        observers.remove(observer)
    }

    //消息通知
    override fun notify(msg: String) {
        observers.forEach {
            it.update(msg)
        }
    }
}